using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Globalization;
using System.Xml.Serialization;
using System.Xml;

namespace CSF.Communications.Sdp.ServiceLogic.Entities
{
    [System.SerializableAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://Microsoft.Csf.Sbe.OrderHandling.ServiceLogic.Schema.Mid")]
    [System.Xml.Serialization.XmlRootAttribute("CSF_MID",Namespace ="http://Microsoft.Csf.Sbe.OrderHandling.ServiceLogic.Schema.Mid", IsNullable = false)]
    public class CSF_MID
    {
        #region Members
        private CSFDataType cSFData = null;
        private ServiceLogicPayloadTypeCSFProfile cSFProfile = null;
        private ServiceLogicPayloadTypeVASData[] vASDataCollection = null;
        private RoutingDataType routingData = null;
        private ServiceLogicCompletionStatus slCompletionStatus = null;
        #endregion

        #region Properties
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public CSFDataType CSFData
        {
            get
            {
                return this.cSFData;
            }
            set
            {
                this.cSFData = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public ServiceLogicPayloadTypeCSFProfile CSFProfile
        {
            get
            {
                return this.cSFProfile;
            }
            set
            {
                this.cSFProfile = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlArrayAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        [System.Xml.Serialization.XmlArrayItemAttribute("VASData", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = false)]
        public ServiceLogicPayloadTypeVASData[] VASDataCollection
        {
            get
            {
                return this.vASDataCollection;
            }
            set
            {
                this.vASDataCollection = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public RoutingDataType RoutingData
        {
            get
            {
                return this.routingData;
            }
            set
            {
                this.routingData = value;
            }
        }

        [System.Xml.Serialization.XmlIgnore]
        public ServiceLogicCompletionStatus ServiceLogicStatus
        {
            get
            {
                return this.slCompletionStatus;
            }
            set
            {
                this.slCompletionStatus = value;
            }
        }


        #endregion

        #region SerializeObject
        /// <summary>
        /// This method returns an xml representation of the object
        /// </summary>
        /// <returns>The xml resprestation as Srting</returns>
        public string SerializeObject()
        {
            StringBuilder serialBuilder;
            StringWriter serialWriter;
            XmlSerializer messageSerializer;
            XmlSerializerNamespaces xmlNamespaces = null;
            try
            {
                serialBuilder = new StringBuilder(1000);
                serialWriter = new StringWriter(serialBuilder, CultureInfo.InvariantCulture);
                messageSerializer = new XmlSerializer(this.GetType());
                xmlNamespaces = new XmlSerializerNamespaces();
                xmlNamespaces.Add("ns0", "http://Microsoft.Csf.Sbe.OrderHandling.ServiceLogic.Schema.Mid");
                xmlNamespaces.Add("ns1", "http://Microsoft.Csf.Sbe.OrderHandling.ServiceLogic.Schema.ServiceLogicCompletionStatus");
                xmlNamespaces.Add("pl", "http://Microsoft.Csf.Sbe.OrderHandling.ServiceLogic.Schema.ServiceLogicPayload");
                xmlNamespaces.Add("rd", "http://Microsoft.Csf.Sbe.OrderHandling.ServiceLogic.Schema.RoutingData");
                messageSerializer.Serialize(serialWriter, this,xmlNamespaces);
                return serialWriter.ToString();
            }
            catch (Exception serializeObjectException)
            {
                throw (serializeObjectException);
            }
            finally
            {
                serialBuilder = null;
                serialWriter = null;
                messageSerializer = null;
            }
        }
        #endregion

        #region DeSerializeObject
        /// <summary>
        /// This method returns an xml representation of the object
        /// </summary>
        /// <returns>The xml representation as Srting</returns>
        public static CSF_MID DeSerializeObject(String xmlString)
        {
            StringReader serialReader;
            XmlSerializer messageSerializer;
            CSF_MID csfMid = null;
           
            try
            {
                serialReader = new StringReader(xmlString);
                messageSerializer = new XmlSerializer(typeof(CSF_MID));
                csfMid = (CSF_MID)messageSerializer.Deserialize(serialReader);
              
            }
            catch (Exception serializeObjectException)
            {
                throw (serializeObjectException);
            }
            finally
            {
                messageSerializer = null;
            }

            return csfMid;
        }
        #endregion
    }

    public class Service
    {
        public string vasId;
        public string[] inputcharacteristics;
        public string[] outputcharacteristics;
        public ServiceLogicPayloadTypeVASData vasdata;
        public XmlDocument vasdataXml;


    }

}
